|
Confluence Docs 3.0 : Rendering Velocity templates in a macro
This page last changed on May 25, 2008 by mryall.
When writing a macro plugin, it's a common requirement to render a Velocity file included with your plugin. The Velocity file should be rendered with some data provided by your plugin. The easiest way to render Velocity templates from within a macro is to use VelocityUtils.getRenderedTemplate and simply return the result as the macro output. You can use it like this:
public String execute(Map params, String body, RenderContext renderContext) throws MacroException {
// do something with params ...
Map context = MacroUtils.defaultVelocityContext();
context.put("page", page);
context.put("labels", labels);
return VelocityUtils.getRenderedTemplate("com/atlassian/confluence/example/sample-velocity.vm", context);
}
See also |
| Document generated by Confluence on Nov 05, 2009 23:34 |